package com.chinasoft.ssm.mapper;

import com.chinasoft.ssm.pojo.Orderhis;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderhisMapper {
    @Insert("insert into orderhis values(null,#{name},#{img},#{userId},#{bikeId},#{count},#{cost})")
    Integer insert(Orderhis bike);
    @Select("select * from orderhis where userId = #{userId} ")
    List<Orderhis> findById(Integer id);
    @Update("update orderhis set name = #{name} ,cost=#{cost}, img = #{img}, userId = #{userId},bikeId=#{bikeId},count=#{count} where id = #{id}  ")
    Integer update(Orderhis bike);
    @Select("select * from orderhis where userId = #{userId} and bikeId = #{bikeId}")
    Orderhis findByBikeId(Integer userId, Integer bikeId);
    @Select("select * from orderhis where id = #{id}")
    Orderhis selectById(Integer id);

    @Delete("delete from orderhis where id = #{id}")
    Integer deleteById(Integer id);

    @Select("select * from orderhis")
    List<Orderhis> getAll();

    List<Orderhis> selectByDSql(Orderhis orderhis);

    @Insert("insert into orderhis values(null,#{userId},#{bikeId},#{img},#{name}," +
            "#{count},#{cost})")
    Integer add(Orderhis orderhis);

    Integer countTotalOrders();
    Double sumTotalCosts();
}
